<?php

/**
 * index.php
 *
 * @package adServer
 */

/*	Load the configuration file	*/
require_once ('config.php');

/*	Load the classes	*/
require_once (CLASS_PATH . 'session.class.php');

/*	Instantiate the session class	*/
$session = new adServerSession();

/*	Determine the action
* 
* If no action is determined, default will be 'login' if user is not logged
* and display if user is already logged 
*/
$nextAction = '';

/*	Check if there is something in the action parameter	*/
if (!isset($_REQUEST['action'])) {
    if ($session->firstRun == true)
        $nextAction = 'createaccount';
    elseif ($session->loggedIn == false)
        $nextAction = 'login';
    else
        $nextAction = 'display';
} else {
    if ($session->loggedIn == false && $_REQUEST['action'] != 'dologin')
        $nextAction = 'login';
    else
        $nextAction = $_REQUEST['action'];
}

/*	Process the next action	*/
if (file_exists(MODULE_PATH . $nextAction . '.php'))
    require_once (MODULE_PATH . $nextAction . '.php');
else
    header('Location:./index.php');

/*	Load the page footer	*/
if (!isset($_GET['nofooter']))
    require_once (TEMPLATE_PATH . 'footer.tpl');

?>
